#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>


int main(){
	int ret;
	char buff[32] = {0};
	//文件描述符
	int fd;
	//创建一个myfifo的管道文件
	ret = mkfifo("/home/linux/CProject/IO/day6_bingfa/myfifo", 0666);
	if(ret < 0){
		perror("mkfifo");
	}

	//以写的方式打开myfifo文件
	fd = open("/home/linux/CProject/IO/day6_bingfa/myfifo",O_WRONLY);
	if(fd < 0){
		perror("open");
		return -1;
	}
	printf("after open\n");

	//往myfifo文件中写入键盘输入的数据
	while(1){
		//fgets会将\n也当成一个字符进行输入
		fgets(buff, 32, stdin);
		write(fd, buff, strlen(buff));
	}





}
